package service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import model.Airport;
import model.Flight;
import model.FlightLeg;
import model.FlightSearchCriteria;
import model.SpecialDeal;

public class FlightServiceImpl implements FlightService {
	 private static final long TWO_HOURS = 1000*60*60*2;
	@Override
	public List<SpecialDeal> getSpecialDeals() {
		// in reality, pull from a database via a DAO
		List<SpecialDeal> specials = new ArrayList<SpecialDeal>();
		specials.add(new SpecialDeal(new Airport("Baltimore", "BWI"),
				new Airport("New York City", "LGA"), new BigDecimal(250),
				new Date(), new Date()));
		specials.add(new SpecialDeal(new Airport("Honolulu", "HNL"),
				new Airport("Orlando", "MCO"), new BigDecimal(500), new Date(),
				new Date()));
		specials.add(new SpecialDeal(new Airport("Tokyo", "NRT"), new Airport(
				"San Francisco", "SFO"), new BigDecimal(700), new Date(),
				new Date()));
		return specials;
	}

	@Override
	public List<Flight> findFlights(FlightSearchCriteria searchCriteria) {
		// in reality, pull from a database via a DAO
		List<Flight> flights = new ArrayList<Flight>();

		List<FlightLeg> legs = new ArrayList<FlightLeg>();
		legs.add(new FlightLeg(new Airport(
				searchCriteria.getDepartureAirport(), "ABC"), new Airport(
				searchCriteria.getArrivalAirport(), "XYZ"), searchCriteria
				.getDapartureDate(), new Date(searchCriteria.getDapartureDate()
				.getTime() + TWO_HOURS)));

		flights.add(new Flight(legs, new BigDecimal(500)));
		return flights;
	}

}
